<?php
/**
 * Created by PhpStorm.
 * User: SQK
 * Date: 2018/8/13
 * Time: 15:41
 */
namespace app\blog\model;
use think\Model;

class AgratioModel extends Model
{
    /**
     * 代理等级列表
     */
    public function index(){
        $result = $this->field('id,agr_level,money,number')
                        ->order('id desc')
                        ->paginate(10);
        return $result;
    }
    /**
     * 添加代理等级
     */
    public function addPost($date){
        $result = $this->insert($date);
        return $result;
    }
    /**
     * 修改代理商等级
     */
    public function change($id,$data){
        $result = $this->where(['id'=>$id])->update($data);
        return $result;
    }
    /**
     * 删除指定代理商
     */
    public function del($id){
        $result = $this->where(['id'=>$id])->delete();
        return $result;
    }
    /**
     * 根据指定id获取记录
     */
    public function getOne($id){
        $result = $this->where(['id'=>$id])->find();
        return $result;
    }
    /**
     * 获取代理商等级（辅助）
     */
    public function getAll(){
        $result = $this->select();
        return $result;
    }

}